package GameOntology;

import java.util.ArrayList;

public class Wall extends GameObject{
    private GameWindow gameWindow;

    private String team="";

    public Wall(String img, int x, int y, GameWindow gameWindow) {
        super(60,60, img, x, y);
        this.gameWindow = gameWindow;
        this.renewalRec(x,y,60,60);
        if (img.equals("game/img/home.gif")){
            team = "base";
        }
    }

    public Wall() {
    }

    public void beHit(){
        ArrayList<Bullet> bullets = gameWindow.bullets;
        for (Bullet bullet : bullets) {
            if (bullet.getRec().intersects(this.getRec())) {
                if (this.team.equals("base")) {
                    gameWindow.setBase(0);
                }
                gameWindow.removeWall.add(this);
                gameWindow.bullets.remove(bullet);
                break;
            }
        }
    }
}
